package com.tensquare.qa.dao;

import com.tensquare.qa.pojo.Problem;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zzb
 * @create 2021/2/21
 */
@Service
public interface ProblemDao extends JpaRepository<Problem,String> {

    //最新问题列表
    @Query(nativeQuery = true,value = "select p.* from tb_pl pl,tb_problem p where p.id=problemid and p.id = ?1 order by createtime desc ")
    List<Problem> findnewlist(Integer labelid, Pageable pageable);

    //热门问答列表
    @Query(nativeQuery = true,value = "select p.* from tb_pl pl,tb_problem p where p.id=problemid and p.id = ?1 order by reply desc ")
    List<Problem> findhotlist(Integer labelid,Pageable pageable);
}
